﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class UserLogin : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {

        }
    }
    protected void imgbtnOK_Click(object sender, ImageClickEventArgs e)
    {
        string uname = txtUname.Text;
        string upwd = txtUpwd.Text;
        string code1 = txtCode.Text;
        string code = (string)Session["code"];
        emoneybussiness.emoneybusiness business = new emoneybussiness.emoneybusiness();
        
        WebUserDAL bll = new WebUserDAL();
        if (code1.Trim().ToLower() == code.Trim())
        {
            //if (uname.StartsWith("ems"))
            //{
            //    Session["username"] = uname;
            //    Session["userpwd"] = upwd;
            //    ClientScript.RegisterStartupScript(GetType(), "a", "this.parent.document.getElementById(\"loginFram\").style.display = \"none\";this.parent.document.location='service_self.aspx';", true);
            //}
            //else
            //{
                if (!business.CheckUserName(uname, upwd))
                {
                    ClientScript.RegisterStartupScript(GetType(), "a", "alert('用户名或密码错误');", true);
                }
                //if (!bll.Web_Login(uname, upwd))
                //{
                //    ClientScript.RegisterStartupScript(GetType(), "a", "alert('用户名或密码错误');", true);
                //}
                else
                {
                    Session["username"] = uname;
                    Session["userpwd"] = upwd;
                    ClientScript.RegisterStartupScript(GetType(), "a", "this.parent.document.getElementById(\"loginFram\").style.display = \"none\";this.parent.document.location='service_self.aspx';", true);
                }
            //}
        }
        else
        {
            txtCode.Text = "";
            ClientScript.RegisterStartupScript(GetType(), "a", "alert('验证码输入不正确');", true);
        }
    }
    protected void forget_Click(object sender, ImageClickEventArgs e)
    {
        Session["fname"] = txtUname.Text;
        ClientScript.RegisterStartupScript(GetType(), "a", "this.parent.document.getElementById(\"loginFram\").style.display = \"none\";this.parent.document.location='service_forgetPwd.aspx';", true);
    }
}